/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.uct.service.plugins  
 */
package com.apache.uct.service.plugins;

import org.apache.log4j.Logger;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.uct.manager.ActManager;

/**
 * description:  机构属性查询
 * @author dwusoft 创建时间：2015-4-1  
 * @Copyright(c)2014:北京--软件技术有限公司
 */
public class ActEntityPlugin implements PluginConnector {

	private Logger log = Logger.getLogger(ActEntityPlugin.class);

	private ActManager actManager;

	/**
	 * TODO 机构属性查询插件(按权限ID或英文全称).<br>  
	 *      参数说明:<br>
	 *      propertyName:属性名称<br>
	 *      propertyValue:属性值
	 */
	public Object execute(ParamsVo vo) throws Exception {

		ResultEntity result = new ResultEntity();
		try {
			result.setResult("true");
			String propertyName = String.valueOf(vo.getParams("propertyName"));
			String propertyValue = String.valueOf(vo.getParams("propertyValue"));
			if ("actId".equals(propertyName) || "fullEname".equals(propertyName)) {
				ParamsVo pvo = new ParamsVo();
				pvo.setParams("propertyName", propertyName);
				pvo.setParams("propertyValue", propertyValue);
				pvo.setKey("ByActProperty");
				result.setEntity(actManager.execute(pvo));
				result.setMessage("查询成功");
			} else {
				result.setMessage("不支持[" + propertyName + "]属性查询");
			}
		} catch (Exception e) {
			result.setResult("false");
			log.error("执行机构查询失败 ", e);
			result.setMessage("机构查询失败！");
		}
		return result;
	}

	public void setActManager(ActManager actManager) {
		this.actManager = actManager;
	}

}
